<template>
<div>
 <Menu mode="horizontal" :theme="theme1" active-name="1">
        <MenuItem name="1" @click.native="newsclick">
            <Icon type="ios-paper" />
            新闻管理
        </MenuItem>
        <MenuItem name="2" @click.native="productclick">
            <Icon type="ios-people" />
            产品管理
        </MenuItem>
        <MenuItem name="3" @click.native="userclick">
            <Icon type="ios-stats" />
            用户管理
        </MenuItem>
        <MenuItem name="4" @click.native="orderclick">
            <Icon type="ios-construct" />
            订单管理
        </MenuItem>
        <br>
    </Menu>
    <Tree :data="data1" ></Tree>

</div>


</template>
<script>
    export default {
        data () {
            return {
                data1:[],
                theme1: 'light',
                type:1
            }
        },
        methods:{
             newsclick(){
                this.type=1;
                this.getdata(this.type);
            },
             productclick(){
                this.type=2;
                this.getdata(this.type);
            },
            userclick(){
                this.type=3;
                this.getdata(this.type);
            },
             orderclick(){
                this.type=4;
                this.getdata(this.type);
            },
            getdata(type){
                this.axios({
                    url:`http://localhost:3000/cate/list/${type}`,
                    method:'post',
                    data:this.data1
                }).then(res=>{
                    console.log(res.data);
                    this.data1=res.data;
                })
            },


        },
        mounted(){
            this.getdata(this.type)
        }

    }
</script>

